package edu.cug.water.crawler.job.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.List;

@Slf4j
public abstract class AbstractCrawlerTask<T> {

    public HttpHeaders headers;

    public String url;

    public HttpEntity httpEntity;

    public MultiValueMap multiValueMap;

    public abstract ResponseEntity<String> getRequestBody();

    public abstract List<T> getDataFromStr(String requestBody);

    protected void init() {
        headers = new HttpHeaders();
        url = "";
        headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
        multiValueMap = new LinkedMultiValueMap();
    }
}
